/**
* All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
*
* MpmProjectTaskServiceAuto
* 项目任务
*
* 修改纪录
* 2021-01-07 版本：1.0 lanjianwei 创建。
* @version 版本：1.0
* @author 作者：lanjianwei
* 创建日期：2021-01-07
*/

package com.topscomm.mpm.service.impl.auto;

import javax.annotation.Resource;
import com.topscomm.basic.IBasicDao;
import com.topscomm.mpm.pojo.MpmProjectEntity;
import com.topscomm.mpm.service.impl.MpmProjectService;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.tap.common.DatacodeCache;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.topscomm.mpm.*;
import com.topscomm.mpm.pojo.MpmProjectTaskEntity;
import com.topscomm.mpm.dao.IMpmProjectTaskDao;
import org.springframework.beans.factory.annotation.Autowired;


public class MpmProjectTaskServiceAuto extends MpmService<MpmProjectTaskEntity,IMpmProjectTaskDao> {
	@Autowired
	private MpmProjectService mpmProjectService;

	/**
	 * @author: lanjianwei
	 * @date: 2021-01-07
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("flowid") != null) {
			temp = mapRow.get("flowid").toString();
			mapRow.put("dispflowid", datacodeCache.getValueDynamic("ApprovalFlow_MpmProjectTask", temp, "id", "name"));
		}
		if (mapRow.get("state") != null) {
			temp = mapRow.get("state").toString();
			mapRow.put("dispstate", datacodeCache.getValueDynamic("TapApprovalBillState", temp, "code", "name"));
		}
		if (mapRow.get("enabled") != null) {
			temp = mapRow.get("enabled").toString();
			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("taskstate") != null) {
			temp = mapRow.get("taskstate").toString();
			mapRow.put("disptaskstate", datacodeCache.getValueDynamic("MpmTaskState", temp, "code", "name"));
		}
		if (mapRow.get("tasktype") != null) {
			temp = mapRow.get("tasktype").toString();
			mapRow.put("disptasktype", datacodeCache.getValueDynamic("MpmTaskType", temp, "code", "name"));
		}
		if (mapRow.get("taskpriority") != null) {
			temp = mapRow.get("taskpriority").toString();
			mapRow.put("disptaskpriority", datacodeCache.getValueDynamic("MpmTaskPriority", temp, "code", "name"));
		}
		if (mapRow.get("customerapproval") != null) {
			temp = mapRow.get("customerapproval").toString();
			mapRow.put("dispcustomerapproval", datacodeCache.getValueDynamic("MpmCustomerApproval", temp, "code", "name"));
		}
		if (mapRow.get("needsupport") != null) {
			temp = mapRow.get("needsupport").toString();
			mapRow.put("dispneedsupport", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("taskupdatefre") != null) {
			temp = mapRow.get("taskupdatefre").toString();
			mapRow.put("disptaskupdatefre", datacodeCache.getValueDynamic("MpmTaskUpdateFre", temp, "code", "name"));
		}
		if (mapRow.get("havenamelist") != null) {
			temp = mapRow.get("havenamelist").toString();
			mapRow.put("disphavenamelist", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("intonamelist") != null) {
			temp = mapRow.get("intonamelist").toString();
			mapRow.put("dispintonamelist", datacodeCache.getValueDynamic("MpmIntoNameList", temp, "code", "name"));
		}
		if (mapRow.get("reviewmeetname") != null) {
			temp = mapRow.get("reviewmeetname").toString();
			mapRow.put("dispreviewmeetname", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("reviewmeetingdocument") != null) {
			temp = mapRow.get("reviewmeetingdocument").toString();
			List<String> list = new ArrayList<>();
			for (String code : temp.split(",")) {
				list.add(datacodeCache.getValueDynamic("ReviewMeetingDocument", code, "code", "name"));
			}
			mapRow.put("dispreviewmeetingdocument", list.stream().collect(Collectors.joining(",")));
		}
	}

	@Override
	@Resource(name = "mpmProjectTaskDao")
	public void setDao(IBasicDao<MpmProjectTaskEntity> dao) {
		super.setDao(dao);
	}
}
